﻿#include "confirmuser.h"
#include "ui_confirmuser.h"
#include <QPainter>
#include "currentuserdata.h"
ConfirmUser::ConfirmUser(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ConfirmUser)
{
    ui->setupUi(this);
    this->setWindowFlags(Qt::Dialog|Qt::FramelessWindowHint);
    setAttribute(Qt::WA_TranslucentBackground,true);

}

ConfirmUser::~ConfirmUser()
{
    delete ui;
}

void ConfirmUser::setUserMsg(const ST_PatientMsg& userMsg)
{
    QString userMessage;
    QString sex;
    if(0 == userMsg.sex)
        sex = tr("男");
    else if(1 == userMsg.sex)
        sex = tr("女");
    userMessage = userMsg.userName  + "  " + sex + "  " + QString::number(userMsg.ID);
    ui->userMassage_label->setText(userMessage);

    CurrentUserData::getInstace()->setCurrentUserMsg(userMsg);
}


bool ConfirmUser::isSelectUser()
{
    return isSelectedUser;
}


void ConfirmUser::paintEvent(QPaintEvent *event)
{
    Q_UNUSED(event)
    QPainter painter(this);
    painter.fillRect(rect(),QColor(0,0,0,100));
}

void ConfirmUser::on_cancel_pushButton_clicked()
{

    isSelectedUser = false;
    this->close();
}

void ConfirmUser::on_confirm_pushButton_clicked()
{
    isSelectedUser = true;


    this->close();
}

void ConfirmUser::changeEvent(QEvent* event)
{
    switch (event->type())
    {
    case QEvent::LanguageChange:
        ui->retranslateUi(this);
        break;
    default:
        QWidget::changeEvent(event);
        break;
    }
}
